<template>
	<view class="equipment">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				维修记录
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="top">
				<view class="left clearfix">
					<view class="mess fl" @click="attrhandle(1)">
						<view :class="[attrIndex==1?'active':'']">全部</view>
						<text class="dian" v-if="attrIndex == 1"></text>
					</view>
					<view class="mess mess1 fl" @click="attrhandle(2)">
						<view :class="[attrIndex==2?'active':'']">待审核</view>
						<text class="dian" v-if="attrIndex == 2"></text>
					</view>
					<view class="mess mess1 fl" @click="attrhandle(3)">
						<view :class="[attrIndex==3?'active':'']">审核不通过</view>
						<text class="dian" v-if="attrIndex == 3"></text>
					</view>
					<view class="mess mess1 fl" @click="attrhandle(4)">
						<view :class="[attrIndex==4?'active':'']">待寄件</view>
						<text class="dian" v-if="attrIndex == 4"></text>
					</view>
					<view class="mess mess1 fl" @click="attrhandle(5)">
						<view :class="[attrIndex==5?'active':'']">取消申请</view>
						<text class="dian" v-if="attrIndex == 5"></text>
					</view>
					<view class="mess mess1 fl" @click="attrhandle(6)">
						<view :class="[attrIndex==6?'active':'']">已寄件</view>
						<text class="dian" v-if="attrIndex == 6"></text>
					</view>
				</view>
			</view>
		</view>
		<view class="content" v-if="recordList.length != 0">
			<view class="list" v-for="(item,index) in recordList" :key="index">
				<view class="top clearfix">
					<image :src="baseUrl + '/wximage/ordertubiao.png'" class="fl"></image>
					<view class="title fl" v-if="item.type==1">充电宝损坏</view>
					<view class="title fl" v-else>机柜损坏</view>
					<view class="money fr" v-if="item.status==2">待审核</view>
					<view class="money fr" v-if="item.status==3">审核不通过</view>
					<view class="money fr" v-if="item.status==4">待寄件</view>
					<view class="money fr" v-if="item.status==5">取消申请</view>
					<view class="money fr" v-if="item.status==6">已寄件</view>
				</view>
				<view class="center">
					<view class="desc">设备编码：{{item.sn}}</view>
					<view class="desc" v-if="item.cause==1">维修原因：不能充电</view>
					<view class="desc" v-if="item.cause==2">维修原因：数据线头摔坏</view>
					<view class="desc" v-if="item.cause==3">维修原因：鼓包</view>
					<view class="desc" v-if="item.cause==4">维修原因：归还无法失败</view>
					<view class="desc" v-if="item.cause==5">维修原因：其他原因</view>
					<view class="desc" v-if="item.cause==6">维修原因：仓口无法识别</view>
					<view class="desc" v-if="item.cause==7">维修原因：无法通电(离线)</view>
					<view class="desc" v-if="item.cause==8">维修原因：叠加层叠加无反应</view>
					<view class="desc" v-if="item.cause==9">维修原因：其他原因</view>
					<view class="desc">收件人：{{item.addressee}}</view>
					<view class="desc">联系方式：{{item.mobile}}</view>
					<view class="desc">收件地址：{{item.address}}</view>
					<view class="desc" v-if="item.status==6">
						快递单号：{{item.danhao}}
					</view>
					<view class="desc" v-if="item.status==4">
						<button @click="tanchu(item)">提交单号</button>
					</view>
				</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image :src="baseUrl + '/wximage/empty.png'"></image>
			<text>暂无相关数据</text>
		</view>
		<view class="beijing" v-if="hidden" @click="hidden = false"></view>
		<view class="tankuang" v-if="hidden">
			<view class="content">
				<view class="title">单号</view>
				<view class="form">
					<textarea placeholder="请输入快递单号" v-model="formData1.danhao"></textarea>
					<view class="submit" @click="submit11">提交</view>
				</view>
			</view>
		</view>
		<!-- <uni-popup ref="popup" type="center" :is-mask-click="true" mask-background-color="#000">
			<view class="" style="width: 750rpx; display: flex;justify-content: center;align-items: center;" >
				<view class="" style="width: 90%;height: 400rpx; background-color: #fff;padding: 20rpx;">
					<view style="display: flex;justify-content: center; align-items: center;margin-top: 60rpx;">
						<text>快递单号：</text> <input type="text" placeholder="请输入快递单号" v-model="formData1.danhao" />
					</view>
					<view style="display: flex;justify-content: center; align-items: center;margin-top: 120rpx;text-align: center;height: 72rpx;line-height: 72rpx;background: linear-gradient(90deg, #65bdfc, #398ef8);border-radius: 36rpx;color: #FFFFFF;font-size: 30rpx;width: 70%;">
						<button style="display: flex;justify-content: center; align-items: center;margin-top: 120rpx;text-align: center;height: 72rpx;line-height: 72rpx;background: linear-gradient(90deg, #65bdfc, #398ef8);border-radius: 36rpx;color: #FFFFFF;font-size: 30rpx;width: 70%;" @click="submit11">提交</button>
					</view>
				</view>
			</view>
		</uni-popup> -->
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				keywords: '',
				list: [1],
				attrIndex: 1,
				formData: {
					 id : uni.getStorageSync('agent_id'),
					 type :1,
					 page:1,
					 pageSize:20
				},
				formData1: {
					id:'',
					danhao:''
				},
				recordList: [],
				arrpop: {},
				hidden: false,
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			this.liluList();
		},
		onReachBottom() {
			this.formData.page = this.formData.page+1;
			this.liluList();
		},
		methods: {
			tanchu(item){
				// this.$refs.popup.open('center');
				this.arrpop = item;
				
				this.hidden = !this.hidden;
			},
			submit11(){
				this.formData1.id = this.arrpop.id;
		
				if(this.formData1.danhao==''||this.formData1.danhao==null||this.formData1.danhao==undefined){
					uni.showToast({
						title: "请输入单号！",
						icon: 'none'
					})
					return false;
				}
				
				this.request({
					url: '/wxdevice/repairupdate',
					data: this.formData1,
					method: "POST"
				}).then(res => {
					if (res.data.code == 200) {
						this.arrpop = {};
						
						uni.showToast({
							title: "提交成功！",
							icon: 'none'
						})
						//关闭弹出层
						// this.$refs.popup.close();
						this.hidden = !this.hidden;
						this.formData1.danhao = '';
						
						this.liluList();
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				});
				
			},
			attrhandle(index){
				this.formData.page = 1;
				this.recordList = [];
				this.attrIndex = index;
				this.liluList();
			},
			liluList(){
				if(this.attrIndex == 1){
					this.formData.type = 1;
				}else if(this.attrIndex == 2){
					this.formData.type = 2;
				}else if(this.attrIndex == 3){
					this.formData.type = 3;
				}else if(this.attrIndex == 4){
					this.formData.type = 4;
				}else if(this.attrIndex == 5){
					this.formData.type = 5;
				}else if(this.attrIndex == 6){
					this.formData.type = 6;
				}
				this.request({
					url: '/wxdevice/repairlist',
					data: this.formData,
					method: "GET"
				}).then(res => {
					if (res.data.code == 200) {
						if(res.data.data.list.length!=0){
							this.recordList = res.data.data.list;
						}
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			topage(url){
				uni.navigateTo({
					url
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.equipment {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				text {
					font-size: 24rpx;
				}

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;
			position: relative;
		
			.top{
				.left {
					.mess {
						height: 48rpx;
						line-height: 48rpx;
						text-align: center;
			
						view {
							font-size: 24rpx;
							color: #333333;
						}
			
						.dian {
							width: 8rpx;
							height: 8rpx;
							background: #5C88FA;
							display: block;
							border-radius: 50%;
							margin: 0 auto;
						}
			
						.active {
							font-size: 32rpx;
							color: #333333;
							font-weight: 700;
							margin-left: 0;
						}
					}
			
					.mess1 {
						margin-left: 20rpx;
					}
				}
			}
		}
		
		.content{
			width: 100%;
			padding: 0 40rpx;
			box-sizing: border-box;
			margin-top: -200rpx;
			position: absolute;
			
			.list{
				width: 100%;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 26rpx;
				box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
				
				.top{
					width: 100%;
					border-bottom: 1rpx solid #F1F1F1;
					padding-bottom: 20rpx;
					
					image{
						width: 72rpx;
						height: 72rpx;
						margin-right: 20rpx;
					}
					
					.title{
						font-size: 28rpx;
						color: #333333;
						margin-top: 22rpx;
						font-weight: 700;
					}
					
					.money{
						font-size: 28rpx;
						color: #8B8CFF;
						margin-top: 22rpx;
						margin-right: 8rpx;
						font-weight: 700;
					}
				}
				
				.center{
					width: 96%;
					margin: 0 auto;
					margin-top: 20rpx;
					
					.desc{
						width: 100%;
						font-size: 24rpx;
						color: #333333;
						line-height: 44rpx;
						
						button{
							text-align: center;
							height: 72rpx;
							line-height: 72rpx;
							background: linear-gradient(90deg, #65bdfc, #398ef8);
							border-radius: 36rpx;
							color: #FFFFFF;
							font-size: 30rpx;
							margin: 0 auto;
							width: 70%;
							margin-top: 20rpx;
						}
					}
					
					.color{
						font-size: 24rpx;
						color: #5C88FA;
					}
				}
			}
		}
		
		.empty{
			width: 100%;
			margin: 200rpx auto 0;
			text-align: center;
			
			image{
				width: 390rpx;
				height: 340rpx;
			}
			
			text{
				display: block;
				margin-top: 60rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
		
		.beijing{
			position: fixed;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
			background: #000000;
			opacity: 0.5;
		}
		
		.tankuang{
			position: fixed;
			width: 80%;
			top: 50%;
			left: 10%;
			
			.content{
				width: 100%;
				background: #ffffff;
				padding-bottom: 30rpx;
				border-radius: 20rpx;
				
				.title{
					width: 100%;
					padding-top: 30rpx;
					text-align: center;
					font-size: 36rpx;
					color: #000000;
					font-weight: 600;
				}
				
				.form{
					width: 86%;
					margin: 0 auto;
					margin-top: 50rpx;
					
					textarea{
						height: 180rpx;
						width: 100%;
						color: #838383;
						background: #f9f9f9;
						font-size: 30rpx;
						padding: 3%;
						box-sizing: border-box;
					}
					
					.submit{
						width: 100%;
						background: linear-gradient(90deg, #65bdfc, #398ef8);
						border-radius: 45rpx;
						border-top-left-radius: 0;
						border-bottom-left-radius: 50rpx;
						color: #ffffff;
						font-size: 30rpx;
						height: 90rpx;
						line-height: 90rpx;
						text-align: center;
						margin-top: 60rpx;
					}
				}
			}
		}
	}
</style>